from django import forms
from .models import Topic

class NewTopicForm(forms.ModelForm):
    message = forms.CharField(
        widget=forms.Textarea(
            attrs={'rows': 5,'placeholder': 'What is on your mind?'}
        ),
        max_length=4000,
        help_text='The max length of the text is 4000.'
        )

    """
    是一个与Topic model相关联的ModelForm.
    Meta类里面fields列表中的subject引用Topic类中的subject field(字段).
    message这个字段用来引用Post中想要保存的message.
    """

    class Meta:
        model = Topic
        fields = ['subject','message']
